package com.sdhs.myproject.service.impl;


import com.sdhs.myproject.domain.ProjectMessage;
import com.sdhs.myproject.mapper.ProjectMessageMapper;
import com.sdhs.myproject.service.ProjectMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class ProjectMessageServiceImpl implements ProjectMessageService {

    @Autowired
    private ProjectMessageMapper projectMessageMapper;

    /**
     * 查询在建项目信息
     */
    @Override
    public List<ProjectMessage> getProjectMessages(ProjectMessage ProjectMessage) {
        return projectMessageMapper.getProjectMessages(ProjectMessage);
    }

    /**
     * 查询项目告警信息
     */
    @Override
    public List<ProjectMessage> getCauseAlarm(ProjectMessage ProjectMessage) {
        return projectMessageMapper.getCauseAlarm(ProjectMessage);
    }

    @Override
    public ProjectMessage getAll() {
        ProjectMessage all = projectMessageMapper.getAll();
        /*未支付合同额*/
        BigDecimal noPay = all.getPayMoney().subtract(all.getIncomeAmount());
        /*未回款合同额*/
        BigDecimal noBack = all.getIncomeMoney().subtract(all.getPayAmount());
        all.setNoPay(noPay);
        all.setNoBack(noBack);
        return all;
    }
    /**
     *  查询 项目收入和项目支出数据（未结束项目）
     *  */
    @Override
    public ProjectMessage getAllInfo() {
        return projectMessageMapper.getAllInfo();
    }

    /**
     *  查询（在建，交工，缺陷责任期，竣工项目数据）以及总数
     *  */
    @Override
    public ProjectMessage getProjectAll() {
        return projectMessageMapper.getProjectAll();
    }

    /**
     *查询重点项目情况
     * */
    @Override
    public List<ProjectMessage> getPeriodList(ProjectMessage ProjectMessage) {
        return projectMessageMapper.getPeriodList(ProjectMessage);
    }
    /**
     * 收入支出项目-下钻 查询项目收入和支出项目数据
     * */
    @Override
    public List<ProjectMessage> getIncomeList(ProjectMessage ProjectMessage) {
        return projectMessageMapper.getIncomeList(ProjectMessage);
    }
}